home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / pd / daten / astrolog / src / charts1.c < prev    next >
C/C++ Source or Header  |  1995-08-11  |  42KB  |  1,398 lines

  1. /*                                                               -*- C -*-
  2. ** Astrolog (Version 4.40) File: charts1.c
  3. **
  4. ** IMPORTANT NOTICE: The graphics database and chart display routines
  5. ** used in this program are Copyright (C) 1991-1995 by Walter D. Pullen
  6. ** (astara@u.washington.edu). Permission is granted to freely use and
  7. ** distribute these routines provided one doesn't sell, restrict, or
  8. ** profit from them in any way. Modification is allowed provided these
  9. ** notices remain with any altered or edited versions of the program.
  10. **
  11. ** The main planetary calculation routines used in this program have
  12. ** been Copyrighted and the core of this program is basically a
  13. ** conversion to C of the routines created by James Neely as listed in
  14. ** Michael Erlewine's 'Manual of Computer Programming for Astrologers',
  15. ** available from Matrix Software. The copyright gives us permission to
  16. ** use the routines for personal use but not to sell them or profit from
  17. ** them in any way.
  18. **
  19. ** The PostScript code within the core graphics routines are programmed
  20. ** and Copyright (C) 1992-1993 by Brian D. Willoughby
  21. ** (brianw@sounds.wa.com). Conditions are identical to those above.
  22. **
  23. ** The extended accurate ephemeris databases and formulas are from the
  24. ** calculation routines in the program "Placalc" and are programmed and
  25. ** Copyright (C) 1989,1991,1993 by Astrodienst AG and Alois Treindl
  26. ** (alois@azur.ch). The use of that source code is subject to
  27. ** regulations made by Astrodienst Zurich, and the code is not in the
  28. ** public domain. This copyright notice must not be changed or removed
  29. ** by any user of this program.
  30. **
  31. ** Initial programming 8/28,30, 9/10,13,16,20,23, 10/3,6,7, 11/7,10,21/1991.
  32. ** X Window graphics initially programmed 10/23-29/1991.
  33. ** PostScript graphics initially programmed 11/29-30/1992.
  34. ** Last code change made 1/29/1995.
  35. */
  36.  
  37. /* $VER: $Id: charts1.c,v 1.2 1995/07/02 22:20:40 tf Exp $ */
  38.  
  39. #include "astrolog.h"
  40.  
  41.  
  42. /*
  43. ******************************************************************************
  44. ** Single Chart Display Routines.
  45. ******************************************************************************
  46. */
  47.  
  48.  
  49. /* Print the straight listing of planet and house positions and specified */
  50. /* by the -v switch, along with the element table, etc.                   */
  51.  
  52. void ChartListing()
  53. {
  54.   ET et;
  55.   char sz[cchSzDef];
  56.   int i, j, k, fNam, fLoc;
  57.   real rT;
  58.  
  59.   CreateElemTable(&et);
  60.   fNam = *ciMain.nam > chNull; fLoc = *ciMain.loc > chNull;
  61.  
  62.   /* Print header showing time and date of the chart being displayed. */
  63.  
  64.   AnsiColor(kWhite);
  65.   sprintf(sz, "%s %s chart ", szAppName, szVersionCore); PrintSz(sz);
  66.  
  67.   if (Mon == -1)
  68.     PrintSz("(No time or space)\n");
  69.  
  70.   else if (us.nRel == rcComposite)
  71.     PrintSz("(Composite)\n");
  72.  
  73.   else
  74.   {
  75.     sprintf(sz, "for %s%s", ciMain.nam, fNam ? "\n" : ""); PrintSz(sz);
  76.     j = DayOfWeek(Mon, Day, Yea);
  77.  
  78.     sprintf(sz, "%c%c%c %s %s (%cT %s GMT)", chDay3(j),
  79.       SzDate(Mon, Day, Yea, 3), SzTim(Tim), Dst != 0.0 ? 'D' : 'S',
  80.       SzZone(Zon)); PrintSz(sz);
  81.  
  82.     sprintf(sz, "%c%s%s%s\n", (fLoc && !fNam) ? '\n' : ' ', ciMain.loc,
  83.       fLoc ? " " : "", SzLocation(Lon, Lat)); PrintSz(sz);
  84.   }
  85.  
  86. #ifdef INTERPRET
  87.   if (us.fInterpret)            /* Print an interpretation if -I in effect. */
  88.   {
  89.     if (us.nRel == rcSynastry)
  90.       InterpretSynastry();      /* Print synastry interpretaion for -r -I.  */
  91.     else
  92.       InterpretLocation();      /* Do normal interpretation for just -v -I. */
  93.     return;
  94.   }
  95. #endif
  96.  
  97.   AnsiColor(kDkGray);
  98.   if (us.fSeconds)
  99.     PrintSz("Body  Location   Ret. Declin.  Rul.      House  Rul. Velocity\n");
  100.  
  101.   else 
  102.   {
  103.     PrintSz("Body  Locat. Ret. Decl. Rul.      House  Rul. Veloc.    ");
  104.     sprintf(sz, "%s Houses.\n", szSystem[us.nHouseSystem]); PrintSz(sz);
  105.   }
  106.  
  107.   if (!fNam && !fLoc)
  108.     PrintL();
  109.  
  110.   /* Ok, now print out the location of each object. */
  111.  
  112.   for (i = 1, j = 1; i <= oNorm; i++, j++) 
  113.   {
  114.     if (us.fSeconds) 
  115.     {
  116.       if (ignore[i])
  117.         continue;
  118.     } 
  119.     else 
  120.     {
  121.       if (i > oCore && (i <= cuspHi || ignore[i]))
  122.         continue;
  123.  
  124.       while (i <= oCore && j <= oCore && ignore[j])
  125.         j++;
  126.     }
  127.  
  128.     if (i <= oCore && j > oCore)
  129.       PrintTab(' ', 51);
  130.  
  131.     else 
  132.     {
  133.       if (i > oCore)
  134.         j = i;
  135.  
  136.       AnsiColor(kObjA[j]);
  137.       sprintf(sz, "%-4.4s: ", szObjName[j]); PrintSz(sz);
  138.       PrintZodiac(planet[j]);
  139.       sprintf(sz, " %c ", ret[j] >= 0.0 ? ' ' : chRet); PrintSz(sz);
  140.  
  141.       if (j <= cThing || j > cuspHi)
  142.         PrintAltitude(planetalt[j]);
  143.       else
  144.         PrintTab('_', us.fSeconds ? 10 : 7);
  145.  
  146.       sprintf(sz, " (%c)", Dignify(j, SFromZ(planet[j])));
  147.       PrintSz(FCusp(j) ? "    " : sz);
  148.       k = inhouse[j];
  149.  
  150.       AnsiColor(kSignA(k));
  151.       sprintf(sz, " [%2d%s house] ", k, szSuffix[k]); PrintSz(sz);
  152.  
  153.       AnsiColor(kDefault);
  154.       sprintf(sz, "[%c] ", Dignify(j, k)); PrintSz(FCusp(j) ? "    " : sz);
  155.  
  156.       if ((j != oMoo || us.fPlacalc) && (FObject(j) || ((j == oNod || j == oLil) && us.fPlacalc)))
  157.       {
  158.         PrintCh((char)((ret[i] < 0.0) ? '-' : '+'));
  159.  
  160.         rT = DFromR(RAbs(ret[j]));
  161.         sprintf(sz, us.fSeconds ? (rT < 10.0 ? "%9.7f" : "%9.6f") :
  162.                                   (rT < 10.0 ? "%5.3f" : "%5.2f"), rT); PrintSz(sz);
  163.       }
  164.       else
  165.         PrintTab('_', us.fSeconds ? 10 : 6);
  166.     }
  167.  
  168.     if (!us.fSeconds)
  169.     {
  170.       /* For some lines, we have to append the house cusp positions. */
  171.  
  172.       if (i <= cSign)
  173.       {
  174.         PrintSz("  -  ");
  175.         AnsiColor(kSignA(i));
  176.         sprintf(sz, "House cusp %2d: ", i); PrintSz(sz);
  177.         PrintZodiac(house[i]);
  178.       }
  179.  
  180.       /* For some lines, we have to append the element table information. */
  181.  
  182.       if (i == cSign+2)
  183.         PrintSz("     Car Fix Mut TOT");
  184.  
  185.       else if (i > cSign+2 && i < cSign+7) 
  186.       {
  187.         k = i-(cSign+2)-1;
  188.         AnsiColor(kElemA[k]);
  189.  
  190.         sprintf(sz, "  %c%c%c%3d %3d %3d %3d",
  191.           szElem[k][0], szElem[k][1], szElem[k][2],
  192.           et.coElemMode[k][0], et.coElemMode[k][1], et.coElemMode[k][2],
  193.           et.coElem[k]); PrintSz(sz);
  194.         AnsiColor(kDefault);
  195.       }
  196.  
  197.       else if (i == cSign+7)
  198.       {
  199.         sprintf(sz, "  TOT %2d %3d %3d %3d",
  200.           et.coMode[0], et.coMode[1], et.coMode[2], et.coSum); PrintSz(sz);
  201.       } 
  202.  
  203.       else if (i == oCore)
  204.         PrintTab(' ', 23);
  205.  
  206.       else if (i >= uranLo)
  207.       {
  208.         sprintf(sz, "  Uranian #%d", i-uranLo+1); PrintSz(sz);
  209.       }
  210.       sz[0] = chNull;
  211.  
  212.       switch (i-cSign-1) {
  213.       case 1: sprintf(sz, "   +:%2d", et.coYang);  break;
  214.       case 2: sprintf(sz, "   -:%2d", et.coYin);   break;
  215.       case 3: sprintf(sz, "   M:%2d", et.coMC);    break;
  216.       case 4: sprintf(sz, "   N:%2d", et.coIC);    break;
  217.       case 5: sprintf(sz, "   A:%2d", et.coAsc);   break;
  218.       case 6: sprintf(sz, "   D:%2d", et.coDes);   break;
  219.       case 7: sprintf(sz,    "<:%2d", et.coLearn); break;
  220.       }
  221.       PrintSz(sz);
  222.     }
  223.  
  224.     else
  225.     {
  226.       PrintSz(" Decan: ");
  227.       is.fSeconds = fFalse;
  228.       PrintZodiac(Decan(planet[i]));
  229.       is.fSeconds = us.fSeconds;
  230.     }
  231.  
  232.     PrintL();
  233.   }
  234.  
  235.   /* Do another loop to print out the stars in their specified order. */
  236.  
  237.   if (us.nStar) for (i = starLo; i <= starHi; i++) if (!ignore[i]) 
  238.   {
  239.     j = oNorm+starname[i-oNorm];
  240.     AnsiColor(kObjA[j]);
  241.     sprintf(sz, "%.4s: ", szObjName[j]); PrintSz(sz);
  242.     PrintZodiac(planet[j]);
  243.     PrintSz("   ");
  244.     PrintAltitude(planetalt[j]);
  245.     k = inhouse[j];
  246.     AnsiColor(kSignA(k));
  247.     sprintf(sz, "     [%2d%s house]", k, szSuffix[k]); PrintSz(sz);
  248.     AnsiColor(kDefault);
  249.     sprintf(sz, "     ______%s Star #%2d: %5.2f\n",
  250.       us.fSeconds ? "____" : " ", i-oNorm, starbright[j-oNorm]); PrintSz(sz);
  251.   }
  252. }
  253.  
  254.  
  255. /* Print out the aspect and midpoint grid for a chart, as specified with the */
  256. /* -g switch. (Each grid row takes up 4 lines of text.)                      */
  257.  
  258. void ChartGrid()
  259. {
  260.   char sz[cchSzDef];
  261.   int x, y, r, x1, y1, temp;
  262.  
  263. #ifdef INTERPRET
  264.   if (us.fInterpret)     /* Print interpretation instead if -I in effect. */
  265.   {
  266.     InterpretGrid();
  267.     return;
  268.   }
  269. #endif
  270.  
  271.   for (y1 = 0, y = 1; y <= cObj; y++) if (!ignore[y])
  272.   {
  273.     for (r = 1; r <= 4; r++)
  274.     {
  275.       for (x1 = 0, x = 1; x <= cObj; x++) if (!ignore[x])
  276.       {
  277.         if (y1 > 0 && x1 > 0 && y+r > 2)
  278.           PrintCh((char)(r > 1 ? chV : chC));
  279.  
  280.         if (r > 1)
  281.         {
  282.           temp = grid->n[x][y];
  283.  
  284.           /* Print aspect rows. */
  285.  
  286.           if (x < y)
  287.           {
  288.             if (temp)
  289.               AnsiColor(kAspA[temp]);
  290.  
  291.             if (r == 2)
  292.               PrintSz(temp ? szAspectAbbrev[temp] : "   ");
  293.  
  294.             else if (!temp)
  295.               PrintSz("   ");
  296.  
  297.             else
  298.             {
  299.               if (r == 3)
  300.               {
  301.                 if (grid->v[x][y] < 6000)
  302.                   sprintf(sz, "%c%2d", us.fAppSep ?
  303.                     (grid->v[x][y] < 0 ? 'a' : 's') :
  304.                     (grid->v[x][y] < 0 ? '-' : '+'), abs(grid->v[x][y])/60);
  305.                 else
  306.                   sprintf(sz, "%3d", abs(grid->v[x][y])/60);
  307.               }
  308.               else
  309.                 sprintf(sz, "%02d'", abs(grid->v[x][y])%60);
  310.  
  311.               PrintSz(sz);
  312.             }
  313.           }
  314.  
  315.           /* Print midpoint rows. */
  316.  
  317.           else if (x > y)
  318.           {
  319.             AnsiColor(kSignA(temp));
  320.             if (r == 2)
  321.             {
  322.               temp = grid->n[x][y];
  323.               sprintf(sz, "%c%c%c", chSig3(temp));
  324.             }
  325.             else if (r == 3)
  326.             {
  327.               sprintf(sz, "%2d%c", grid->v[x][y]/60, chDeg0);
  328.             }
  329.             else
  330.               sprintf(sz, "%02d'", grid->v[x][y]%60);
  331.  
  332.             PrintSz(sz);
  333.           }
  334.  
  335.           /* Print the diagonal of object names. */
  336.  
  337.           else
  338.           {
  339.             AnsiColor(kReverse);
  340.             if (r == 2) {
  341.               AnsiColor(kObjA[y]);
  342.               sprintf(sz, "%c%c%c", chObj3(y));
  343.             } else {
  344.               temp = SFromZ(planet[y]);
  345.               AnsiColor(kSignA(temp));
  346.               if (r == 3)
  347.                 sprintf(sz, "%2d%c", (int)planet[y] - (temp-1)*30, chDeg0);
  348.               else
  349.                 sprintf(sz, "%c%c%c", chSig3(temp));
  350.             }
  351.             PrintSz(sz);
  352.           }
  353.           AnsiColor(kDefault);
  354.         } else
  355.           if (y1 > 0)
  356.             PrintTab(chH, 3);
  357.         x1++;
  358.       }
  359.       if (y+r > 2)
  360.         PrintL();
  361.       y1++;
  362.     }
  363.   }
  364. }
  365.  
  366.  
  367. /* This is a subprocedure of DisplayGrands(). Here we print out one aspect */
  368. /* configuration found by the parent procedure.                            */
  369.  
  370. void PrintGrand(ac, i1, i2, i3, i4)
  371. char ac;
  372. int i1, i2, i3, i4;
  373. {
  374.   char sz[cchSzDef];
  375.   int asp;
  376.  
  377.   switch (ac) {
  378.   case acS : asp = aCon; break;
  379.   case acGT: asp = aTri; break;
  380.   case acTS: asp = aOpp; break;
  381.   case acY : asp = aInc; break;
  382.   case acGC: asp = aSqu; break;
  383.   case acC : asp = aSex; break;
  384.   default: ;
  385.   }
  386.  
  387.   AnsiColor(kAspA[asp]);
  388.   sprintf(sz, "%-11s", szAspectConfig[ac]); PrintSz(sz);
  389.  
  390.   AnsiColor(kDefault);
  391.   sprintf(sz, " %s ",
  392.     ac == acS || ac == acGT || ac == acGC ? "with" : "from"); PrintSz(sz);
  393.  
  394.   AnsiColor(kObjA[i1]);
  395.   sprintf(sz, "%c%c%c: ", chObj3(i1)); PrintSz(sz);
  396.   PrintZodiac(planet[i1]);
  397.   sprintf(sz, " %s ", ac == acS || ac == acGT ? "and" : "to "); PrintSz(sz);
  398.  
  399.   AnsiColor(kObjA[i2]);
  400.   sprintf(sz, "%c%c%c: ", chObj3(i2)); PrintSz(sz);
  401.   PrintZodiac(planet[i2]);
  402.   sprintf(sz, " %s ", ac == acGC || ac == acC ? "to " : "and"); PrintSz(sz);
  403.  
  404.   AnsiColor(kObjA[i3]);
  405.   sprintf(sz, "%c%c%c: ", chObj3(i3)); PrintSz(sz);
  406.   PrintZodiac(planet[i3]);
  407.   if (ac == acGC || ac == acC) {
  408.     PrintSz(" to ");
  409.     AnsiColor(kObjA[i4]);
  410.     sprintf(sz, "%c%c%c: ", chObj3(i4)); PrintSz(sz);
  411.     PrintZodiac(planet[i4]);
  412.   }
  413.   PrintL();
  414. }
  415.  
  416.  
  417. /* Scan the aspect grid of a chart and print out any major configurations, */
  418. /* as specified with the -g0 switch.                                       */
  419.  
  420. void DisplayGrands()
  421. {
  422.   int cac = 0, i, j, k, l;
  423.  
  424.   for (i = 1; i <= cObj; i++) if (!ignore[i])
  425.     for (j = 1; j <= cObj; j++) if (j != i && !ignore[j])
  426.       for (k = 1; k <= cObj; k++) if (k != i && k != j && !ignore[k]) {
  427.  
  428.         /* Is there a Stellium among the current three planets? */
  429.  
  430.         if (i < j && j < k && grid->n[i][j] == aCon &&
  431.             grid->n[i][k] == aCon && grid->n[j][k] == aCon) {
  432.           cac++;
  433.           PrintGrand(acS, i, j, k, l);
  434.  
  435.         /* Is there a Grand Trine? */
  436.  
  437.         } else if (i < j && j < k && grid->n[i][j] == aTri &&
  438.             grid->n[i][k] == aTri && grid->n[j][k] == aTri) {
  439.           cac++;
  440.           PrintGrand(acGT, i, j, k, l);
  441.  
  442.         /* Is there a T-Square? */
  443.  
  444.         } else if (j < k && grid->n[j][k] == aOpp &&
  445.             grid->n[Min(i, j)][Max(i, j)] == aSqu &&
  446.             grid->n[Min(i, k)][Max(i, k)] == aSqu) {
  447.           cac++;
  448.           PrintGrand(acTS, i, j, k, l);
  449.  
  450.         /* Is there a Yod? */
  451.  
  452.         } else if (j < k && grid->n[j][k] == aSex &&
  453.             grid->n[Min(i, j)][Max(i, j)] == aInc &&
  454.             grid->n[Min(i, k)][Max(i, k)] == aInc) {
  455.           cac++;
  456.           PrintGrand(acY, i, j, k, l);
  457.         }
  458.         for (l = 1; l <= cObj; l++) if (!ignore[l]) {
  459.  
  460.           /* Is there a Grand Cross among the current four planets? */
  461.  
  462.           if (i < j && i < k && i < l && j < l && grid->n[i][j] == aSqu &&
  463.               grid->n[Min(j, k)][Max(j, k)] == aSqu &&
  464.               grid->n[Min(k, l)][Max(k, l)] == aSqu &&
  465.               grid->n[i][l] == aSqu &&
  466.               MinDistance(planet[i], planet[k]) > 150.0 &&
  467.               MinDistance(planet[j], planet[l]) > 150.0) {
  468.             cac++;
  469.             PrintGrand(acGC, i, j, k, l);
  470.  
  471.           /* Is there a Cradle? */
  472.  
  473.           } else if (i < l && grid->n[Min(i, j)][Max(i, j)] == aSex &&
  474.               grid->n[Min(j, k)][Max(j, k)] == aSex &&
  475.               grid->n[Min(k, l)][Max(k, l)] == aSex &&
  476.               MinDistance(planet[i], planet[l]) > 150.0) {
  477.             cac++;
  478.             PrintGrand(acC, i, j, k, l);
  479.           }
  480.         }
  481.       }
  482.   if (!cac)
  483.     PrintSz("No major configurations in aspect grid.\n");
  484. }
  485.  
  486.  
  487. /* This is subprocedure of ChartWheel(). Here we print out the location */
  488. /* of a particular house cusp as well as what house cusp number it is.  */
  489.  
  490. void PrintHouse(i, left)
  491. int i, left;
  492. {
  493.   char sz[cchSzDef];
  494.  
  495.   if (!left)
  496.     PrintZodiac(house[i]);
  497.   AnsiColor(kSignA(i));
  498.   sprintf(sz, "<%d>", i); PrintSz(sz);
  499.   if (left)
  500.     PrintZodiac(house[i]);
  501.   else
  502.     AnsiColor(kDefault);
  503. }
  504.  
  505.  
  506. /* Another subprocedure of ChartWheel(). Print out one of the chart info */
  507. /* rows in the middle of the wheel (which may be blank) given an index.  */
  508.  
  509. void PrintWheelCenter(irow)
  510. int irow;
  511. {
  512.   char sz[cchSzDef];
  513.   int cch, nT;
  514.  
  515.   if (*ciMain.nam == chNull && irow >= 2)    /* Don't have blank lines if */
  516.     irow++;                                  /* the name and/or location  */
  517.   if (*ciMain.loc == chNull && irow >= 4)    /* strings are empty.        */
  518.     irow++;
  519.   switch (irow) {
  520.   case 1:
  521.     sprintf(sz, "%s %s chart", szAppName, szVersionCore);
  522.     break;
  523.   case 2:
  524.     sprintf(sz, "%s", ciMain.nam);
  525.     break;
  526.   case 3:
  527.     nT = DayOfWeek(Mon, Day, Yea);
  528.     sprintf(sz, "%c%c%c %s %s", chDay3(nT), SzDate(Mon, Day, Yea, 2),
  529.       SzTim(Tim));
  530.     break;
  531.   case 4:
  532.     sprintf(sz, "%s", ciMain.loc);
  533.     break;
  534.   case 5:
  535.     nT = (int)(RFract(RAbs(Zon))*100.0+rRound);
  536.     sprintf(sz, "%cT %c%02d:%02d, %s", Dst != 0.0 ? 'D' : 'S',
  537.       Zon > 0.0 ? '-' : '+', (int)RAbs(Zon), nT, SzLocation(Lon, Lat));
  538.     break;
  539.   case 6:
  540.     sprintf(sz, "%s Houses", szSystem[us.nHouseSystem]);
  541.     break;
  542.   case 7:
  543.     sprintf(sz, "Julian Day = %12.4f", JulianDayFromTime(T));
  544.     break;
  545.   default:
  546.     *sz = chNull;
  547.   }
  548.   cch = CchSz(sz);
  549.   nT = WHEELCOLS*2-1 + is.fSeconds*8;
  550.   PrintTab(' ', (nT - cch) / 2);
  551.   PrintSz(sz);
  552.   PrintTab(' ', nT-cch - (nT - cch) / 2);
  553. }
  554.  
  555.  
  556. /* Yet another subprocedure of ChartWheel(). Here we print out one line */
  557. /* in a particular house cell (which may be blank).                     */
  558.  
  559. void PrintWheelSlot(obj)
  560. int obj;
  561. {
  562.   char sz[cchSzDef];
  563.  
  564.   if (obj) {
  565.     AnsiColor(kObjA[obj]);
  566.     sprintf(sz, " %c%c%c ", chObj3(obj)); PrintSz(sz);
  567.     PrintZodiac(planet[obj]);
  568.     sprintf(sz, "%c ", ret[obj] < 0.0 ? 'r' : ' '); PrintSz(sz);
  569.     PrintTab(' ', WHEELCOLS-15);
  570.   } else                            /* This particular line is blank. */
  571.     PrintTab(' ', WHEELCOLS-1 + is.fSeconds*4);
  572. }
  573.  
  574.  
  575. /* Display all the objects in a wheel format on the screen, as specified */
  576. /* with the -w switch. The wheel is divided into the 12 houses and the   */
  577. /* planets are placed accordingly.                                       */
  578.  
  579. void ChartWheel()
  580. {
  581.   byte wheel[cSign][WHEELROWS];
  582.   int wheelcols, count = 0, i, j, k, l;
  583.  
  584.   /* If the seconds (-b0) flag is set, we'll print all planet and house    */
  585.   /* locations to the nearest zodiac second instead of just to the minute. */
  586.  
  587.   wheelcols = WHEELCOLS + is.fSeconds*4;
  588.  
  589.   for (i = 0; i < cSign; i++)
  590.     for (j = 0; j < us.nWheelRows; j++)    /* Clear out array from the */
  591.       wheel[i][j] = 0;                     /* last time we used it.    */
  592.  
  593.   /* This section of code places each object in the wheel house array. */
  594.  
  595.   for (i = 1; i <= cObj && count < us.nWheelRows*12; i++) {
  596.     if (ignore[i] || !(i < oMC || i == oCore || i > cuspHi))
  597.       continue;
  598.  
  599.     /* Try to put object in its proper house. If no room, */
  600.     /* then overflow over to the succeeding house.        */
  601.  
  602.     for (j = inhouse[i]-1; j < cSign; j = j < cSign ? (j+1)%cSign : j) {
  603.  
  604.       /* Now try to find the proper place in the house to put the object. */
  605.       /* This is in sorted order, although a check is made for 0 Aries.   */
  606.  
  607.       if (wheel[j][us.nWheelRows-1] > 0)
  608.         continue;
  609.       l = house[j+1] > house[Mod12(j+2)];
  610.       for (k = 0; wheel[j][k] > 0 && (planet[i] >= planet[wheel[j][k]] ||
  611.          (l && planet[i] < rDegHalf && planet[wheel[j][k]] > rDegHalf)) &&
  612.         !(l && planet[i] > rDegHalf && planet[wheel[j][k]] < rDegHalf); k++)
  613.         ;
  614.  
  615.       /* Actually insert object in proper place. */
  616.  
  617.       if (wheel[j][k] <= 0)
  618.         wheel[j][k] = i;
  619.       else {
  620.         for (l = us.nWheelRows-1; l > k; l--)
  621.           wheel[j][l] = wheel[j][l-1];
  622.         wheel[j][k] = i;
  623.       }
  624.       count++;
  625.       j = cSign;
  626.     }
  627.   }
  628.  
  629.   /* Now, if this is really the -w switch and not -w0, then reverse the */
  630.   /* order of objects in western houses for more intuitive reading.     */
  631.  
  632.   if (!us.fWheelReverse)
  633.     for (i = 3; i < 9; i++)
  634.       for (j = 0; j < us.nWheelRows/2; j++) {
  635.         k = us.nWheelRows-1-j;
  636.         l = wheel[i][j]; wheel[i][j] = wheel[i][k]; wheel[i][k] = l;
  637.       }
  638.  
  639.   /* Here we actually print the wheel and the objects in it. */
  640.  
  641.   PrintCh(chNW); PrintTab(chH, WHEELCOLS-8); PrintHouse(11, fTrue);
  642.   PrintTab(chH, WHEELCOLS-11); PrintHouse(10, fTrue);
  643.   PrintTab(chH, WHEELCOLS-10); PrintHouse(9, fTrue);
  644.   PrintTab(chH, wheelcols-4); PrintCh(chNE); PrintL();
  645.   for (i = 0; i < us.nWheelRows; i++) {
  646.     for (j = 10; j >= 7; j--) {
  647.       PrintCh(chV); PrintWheelSlot(wheel[j][i]);
  648.     }
  649.     PrintCh(chV); PrintL();
  650.   }
  651.   PrintHouse(12, fTrue); PrintTab(chH, WHEELCOLS-11);
  652.   PrintCh(chC); PrintTab(chH, wheelcols-1); PrintCh(chJN);
  653.   PrintTab(chH, wheelcols-1); PrintCh(chC); PrintTab(chH, WHEELCOLS-10);
  654.   PrintHouse(8, fFalse); PrintL();
  655.   for (i = 0; i < us.nWheelRows; i++) {
  656.     PrintCh(chV); PrintWheelSlot(wheel[11][i]); PrintCh(chV);
  657.     PrintWheelCenter(i);
  658.     PrintCh(chV); PrintWheelSlot(wheel[6][i]);
  659.     PrintCh(chV); PrintL();
  660.   }
  661.   PrintHouse(1, fTrue); PrintTab(chH, WHEELCOLS-10);
  662.   PrintCh(chJW); PrintWheelCenter(us.nWheelRows); PrintCh(chJE);
  663.   PrintTab(chH, WHEELCOLS-10); PrintHouse(7, fFalse); PrintL();
  664.   for (i = 0; i < us.nWheelRows; i++) {
  665.     PrintCh(chV); PrintWheelSlot(wheel[0][i]); PrintCh(chV);
  666.     PrintWheelCenter(us.nWheelRows+1 + i);
  667.     PrintCh(chV); PrintWheelSlot(wheel[5][i]);
  668.     PrintCh(chV); PrintL();
  669.   }
  670.   PrintHouse(2, fTrue); PrintTab(chH, WHEELCOLS-10);
  671.   PrintCh(chC); PrintTab(chH, wheelcols-1); PrintCh(chJS);
  672.   PrintTab(chH, wheelcols-1); PrintCh(chC);
  673.   PrintTab(chH, WHEELCOLS-10); PrintHouse(6, fFalse); PrintL();
  674.   for (i = 0; i < us.nWheelRows; i++) {
  675.     for (j = 1; j <= 4; j++) {
  676.       PrintCh(chV); PrintWheelSlot(wheel[j][i]);
  677.     }
  678.     PrintCh(chV); PrintL();
  679.   }
  680.   PrintCh(chSW); PrintTab(chH, wheelcols-4); PrintHouse(3, fFalse);
  681.   PrintTab(chH, WHEELCOLS-10); PrintHouse(4, fFalse);
  682.   PrintTab(chH, WHEELCOLS-10); PrintHouse(5, fFalse);
  683.   PrintTab(chH, WHEELCOLS-7); PrintCh(chSE); PrintL();
  684. }
  685.  
  686.  
  687. /* Display all aspects between objects in the chart, one per line, in       */
  688. /* sorted order based on the total "power" of the aspect, as specified with */
  689. /* the -a switch. The same influences used for -I charts are used here.     */
  690.  
  691. void ChartAspect()
  692. {
  693.   int ca[cAspect + 1], co[objMax];
  694.   char sz[cchSzDef];
  695.   int pcut = 30000, icut, jcut, phi, ihi, jhi, ahi, p, i, j, k, count = 0;
  696.   real ip, jp, rPowSum = 0.0;
  697.  
  698.   ClearB((lpbyte)ca, (cAspect + 1)*(int)sizeof(int));
  699.   ClearB((lpbyte)co, objMax*(int)sizeof(int));
  700.   loop {
  701.     phi = -1;
  702.  
  703.     /* Search for the next most powerful aspect in the aspect grid. */
  704.  
  705.     for (i = 2; i <= cObj; i++) if (!ignore[i])
  706.       for (j = 1; j < i; j++) if (!ignore[j])
  707.         if (k = grid->n[j][i]) {
  708.           ip = i <= oNorm ? objectinf[i] : 2.5;
  709.           jp = j <= oNorm ? objectinf[j] : 2.5;
  710.           p = (int)(aspectinf[k]*(ip+jp)/2.0*
  711.             (1.0-RAbs((real)(grid->v[j][i]))/60.0/aspectorb[k])*1000.0);
  712.           if ((p < pcut || (p == pcut && (i > icut ||
  713.             (i == icut && j > jcut)))) && p > phi) {
  714.             ihi = i; jhi = j; phi = p; ahi = k;
  715.           }
  716.         }
  717.     if (phi < 0)    /* Exit when no less powerful aspect found. */
  718.       break;
  719.     pcut = phi; icut = ihi; jcut = jhi;
  720.     count++;                               /* Display the current aspect.   */
  721. #ifdef INTERPRET
  722.     if (us.fInterpret) {                   /* Interpret it if -I in effect. */
  723.       InterpretAspect(jhi, ihi);
  724.       continue;
  725.     }
  726. #endif
  727.     rPowSum += (real)phi/1000.0;
  728.     ca[ahi]++;
  729.     co[jhi]++; co[ihi]++;
  730.     sprintf(sz, "%3d: ", count); PrintSz(sz);
  731.     PrintAspect(jhi, SFromZ(planet[jhi]), (int)RSgn(ret[jhi]), ahi,
  732.       ihi, SFromZ(planet[ihi]), (int)RSgn(ret[ihi]), 'a');
  733.     k = grid->v[jhi][ihi];
  734.     AnsiColor(k < 0 ? kWhite : kLtGray);
  735.     sprintf(sz, " - orb: %c%d%c%02d'",
  736.       us.fAppSep ? (k < 0 ? 'a' : 's') : (k < 0 ? '-' : '+'),
  737.       abs(k)/60, chDeg1, abs(k)%60); PrintSz(sz);
  738.     AnsiColor(kDkGreen);
  739.     sprintf(sz, " - power:%6.2f\n", (real)phi/1000.0); PrintSz(sz);
  740.     AnsiColor(kDefault);
  741.   }
  742.  
  743.   /* Now, if the -a0 switch is set, display summary information, the total */
  744.   /* number of aspects of each type, and the # of aspects to each object.  */
  745.  
  746.   if (!us.fAspSummary)
  747.     return;
  748.   PrintL();
  749.   AnsiColor(kDkGreen);
  750.   sprintf(sz, "Sum power:%7.2f - Average power:%6.2f\n",
  751.     rPowSum, rPowSum/(real)count); PrintSz(sz);
  752.   k = us.fParallel ? Min(us.nAsp, aOpp) : us.nAsp;
  753.   for (j = 0, i = 1; i <= k; i++) if (!ignorea(i)) {
  754.     if (!(j & 7)) {
  755.       if (j)
  756.         PrintL();
  757.     } else
  758.       PrintSz("   ");
  759.     AnsiColor(kAspA[i]);
  760.     sprintf(sz, "%s:%3d", szAspectAbbrev[i], ca[i]); PrintSz(sz);
  761.     j++;
  762.   }
  763.   PrintL();
  764.   for (j = 0, i = 1; i <= cObj; i++) if (!ignore[i]) {
  765.     if (!(j & 7)) {
  766.       if (j)
  767.         PrintL();
  768.     } else
  769.       PrintSz("   ");
  770.     AnsiColor(kObjA[i]);
  771.     sprintf(sz, "%c%c%c:%3d", chObj3(i), co[i]); PrintSz(sz);
  772.     j++;
  773.   }
  774.   PrintL();
  775. }
  776.  
  777.  
  778. /* Display locations of all midpoints between objects in the chart, */
  779. /* one per line, in sorted zodiac order from zero Aries onward, as  */
  780. /* specified with the -m switch.                                    */
  781.  
  782. void ChartMidpoint()
  783. {
  784.   int cs[cSign + 1];
  785.   char sz[cchSzDef];
  786.   int mcut = -1, icut, jcut, mlo, ilo, jlo, m, i, j, count = 0;
  787.   long lSpanSum = 0;
  788.  
  789.   ClearB((lpbyte)cs, (cSign + 1)*(int)sizeof(int));
  790.   is.fSeconds = fFalse;
  791.   loop {
  792.     mlo = 21600;
  793.  
  794.     /* Search for the next closest midpoint farther down in the zodiac. */ 
  795.  
  796.     for (i = 1; i < cObj; i++) if (!ignore[i])
  797.       for (j = i+1; j <= cObj; j++) if (!ignore[j]) {
  798.         m = (grid->n[j][i]-1)*30*60 + grid->v[j][i];
  799.         if ((m > mcut || (m == mcut && (i > icut ||
  800.           (i == icut && j > jcut)))) && m < mlo) {
  801.           ilo = i; jlo = j; mlo = m;
  802.         }
  803.       }
  804.     if (mlo >= 21600)    /* Exit when no midpoint farther in zodiac found. */
  805.       break;
  806.     mcut = mlo; icut = ilo; jcut = jlo;
  807.     count++;                               /* Display the current midpoint. */
  808. #ifdef INTERPRET
  809.     if (us.fInterpret) {                   /* Interpret it if -I in effect. */
  810.       InterpretMidpoint(ilo, jlo);
  811.       continue;
  812.     }
  813. #endif
  814.     cs[mlo/60/30+1]++;
  815.     sprintf(sz, "%4d: ", count); PrintSz(sz);
  816.     PrintZodiac((real)mlo/60.0);
  817.     PrintCh(' ');
  818.     PrintAspect(ilo, SFromZ(planet[ilo]), (int)RSgn(ret[ilo]), 0,
  819.       jlo, SFromZ(planet[jlo]), (int)RSgn(ret[jlo]), 'm');
  820.     AnsiColor(kDefault);
  821.     m = (int)(MinDistance(planet[ilo], planet[jlo])*60.0);
  822.     lSpanSum += m;
  823.     sprintf(sz, "-%4d%c%02d' degree span.\n", m/60, chDeg1, m%60);
  824.     PrintSz(sz);
  825.   }
  826.   is.fSeconds = us.fSeconds;
  827.  
  828.   /* Now, if the -m0 switch is set, display summary information as well, */
  829.   /* including the total number of midpoints in each sign.               */
  830.  
  831.   if (!us.fMidSummary)
  832.     return;
  833.   PrintL();
  834.   m = (int)(lSpanSum/count);
  835.   sprintf(sz, "Average span:%4d%c%02d'\n", m/60, chDeg1, m%60); PrintSz(sz);
  836.   for (i = 1; i <= cSign; i++) {
  837.     if (i == sLib)
  838.       PrintL();
  839.     else if (i != sAri)
  840.       PrintSz("   ");
  841.     AnsiColor(kSignA(i));
  842.     sprintf(sz, "%c%c%c:%3d", chSig3(i), cs[i]); PrintSz(sz);
  843.   }
  844.   PrintL();
  845. }
  846.  
  847.  
  848. /* Display locations of the objects on the screen with respect to the local */
  849. /* horizon, as specified with the -Z switch.                                */
  850.  
  851. void ChartHorizon()
  852. {
  853.   char sz[cchSzDef], szFormat[cchSzDef];
  854.   real lon, lat, sx, sy, vx, vy,
  855.     lonz[objMax], latz[objMax], azi[objMax], alt[objMax];
  856.   int fPrime, i, j, k, tot;
  857.  
  858.   /* Set up some initial variables. */
  859.  
  860.   fPrime = us.fPrimeVert;
  861.   lon = RFromD(Mod(Lon)); lat = RFromD(Lat);
  862.   tot = us.nStar ? cObj : oNorm;
  863.  
  864.   /* First find zenith location on Earth of each object. */
  865.  
  866.   for (i = 1; i <= tot; i++) if (!ignore[i] || i == oMC) {
  867.     lonz[i] = RFromD(Tropical(planet[i])); latz[i] = RFromD(planetalt[i]);
  868.     EclToEqu(&lonz[i], &latz[i]);
  869.   }
  870.  
  871.   /* Then, convert this to local horizon altitude and azimuth. */
  872.  
  873.   for (i = 1; i <= tot; i++) if (!ignore[i] && i != oMC) {
  874.     lonz[i] = RFromD(Mod(DFromR(lonz[oMC]-lonz[i]+lon)));
  875.     lonz[i] = RFromD(Mod(DFromR(lonz[i]-lon+rPiHalf)));
  876.     EquToLocal(&lonz[i], &latz[i], rPiHalf-lat);
  877.     azi[i] = rDegMax-DFromR(lonz[i]); alt[i] = DFromR(latz[i]);
  878.   }
  879.  
  880.   /* If the -Z0 switch flag is in effect, convert from altitude/azimuth  */
  881.   /* coordinates to prime vertical coordinates that we'll print instead. */
  882.  
  883.   if (fPrime) {
  884.     for (i = 1; i <= tot; i++) if (!ignore[i]) {
  885.       azi[i] = RFromD(azi[i]); alt[i] = RFromD(alt[i]);
  886.       CoorXform(&azi[i], &alt[i], rPiHalf);
  887.       azi[i] = DFromR(azi[i]); alt[i] = DFromR(alt[i]);
  888.     }
  889.   }
  890.  
  891.   /* Now, actually print the location of each object. */
  892.  
  893.   sprintf(szFormat, is.fSeconds ? " " : "");
  894.   sprintf(sz, "Body %s%sAltitude%s %s%sAzimuth%s%s  Azi. Vector%s    ",
  895.     szFormat, szFormat, szFormat, szFormat, szFormat, szFormat, szFormat,
  896.     szFormat); PrintSz(sz);
  897.   sprintf(sz, "%s Vector%s%s    Moon Vector\n\n",
  898.     us.objCenter ? "Sun" : "Earth", szFormat, szFormat); PrintSz(sz);
  899.   for (k = 1; k <= tot; k++) {
  900.     i = k <= oNorm ? k : oNorm+starname[k-oNorm];
  901.     if (ignore[i] || !FThing(i))
  902.       continue;
  903.     AnsiColor(kObjA[i]);
  904.     sprintf(sz, "%-4.4s: ", szObjName[i]); PrintSz(sz);
  905.     PrintAltitude(alt[i]);
  906.  
  907.     /* Determine directional vector based on azimuth. */
  908.  
  909.     sprintf(sz, " %s", SzDegree(azi[i])); PrintSz(sz);
  910.     sx = RCos(RFromD(azi[i])); sy = RSin(RFromD(azi[i]));
  911.     if (RAbs(sx) < RAbs(sy)) {
  912.       vx = RAbs(sx / sy); vy = 1.0;
  913.     } else {
  914.       vy = RAbs(sy / sx); vx = 1.0;
  915.     }
  916.     sprintf(sz, is.fSeconds ? " (%.3f%c" : " (%.2f%c", vy,
  917.       sy < 0.0 ? (fPrime ? 'u' : 's') : (fPrime ? 'd' : 'n')); PrintSz(sz);
  918.     sprintf(sz, is.fSeconds ? " %.2f%c)" : " %.2f%c)", vx,
  919.       sx > 0.0 ? 'e' : 'w'); PrintSz(sz);
  920.  
  921.     /* Determine distance vector of current object from Sun and Moon. */
  922.  
  923.     vx = azi[1]-azi[i]; vy = azi[2]-azi[i];
  924.     j = 1 + is.fSeconds;
  925.     sprintf(szFormat, " [%%%d.%df%%%d.%df] [%%%d.%df%%%d.%df]",
  926.       j+5, j, j+5, j, j+5, j, j+5, j);
  927.     sprintf(sz, szFormat,
  928.       RAbs(vx) < rDegHalf ? vx : RSgn(vx)*(rDegMax-RAbs(vx)), alt[1]-alt[i],
  929.       RAbs(vy) < rDegHalf ? vy : RSgn(vy)*(rDegMax-RAbs(vy)), alt[2]-alt[i]);
  930.     PrintSz(sz);
  931.     if (!is.fSeconds && i >= uranLo) {
  932.       if (i <= uranHi)
  933.         sprintf(sz, "  Uranian #%d", i-uranLo+1);
  934.       else
  935.         sprintf(sz, "  Star #%2d", i-starLo+1);
  936.       PrintSz(sz);
  937.     }
  938.     PrintL();
  939.   }
  940.   AnsiColor(kDefault);
  941. }
  942.  
  943.  
  944. /* Display x,y,z locations of each body (in AU) with respect to the Sun */
  945. /* (or whatever the specified center planet is), as in the -S switch.   */
  946. /* These values were already determined when calculating the planet     */
  947. /* positions themselves, so this procedure is basically just a loop.    */
  948.  
  949. void ChartOrbit()
  950. {
  951.   char sz[cchSzDef], szFormat[cchSzDef];
  952.   real x, y, z;
  953.   int i;
  954.  
  955.   sprintf(szFormat, is.fSeconds ? " " : "");
  956.   sprintf(sz, "Body%s    Angle%s%s%s%s    ",
  957.     szFormat, szFormat, szFormat, szFormat, szFormat);
  958.   PrintSz(sz);
  959.   sprintf(sz,
  960.     "%sX axis%s%s%s    %sY axis%s%s%s    %sZ axis%s%s%s    %sLength\n",
  961.     szFormat, szFormat, szFormat, szFormat, szFormat, szFormat, szFormat,
  962.     szFormat, szFormat, szFormat, szFormat, szFormat, szFormat);
  963.   PrintSz(sz);
  964.   for (i = 0; i <= oNorm; i++) {
  965.     if (ignore[i] || 
  966.       (!FThing(i) || ((i == oMoo || i == oSou) && !us.fPlacalc)))
  967.       continue;
  968.     AnsiColor(kObjA[i]);
  969.     sprintf(sz, "%c%c%c%c: ", chObj3(i),
  970.       szObjName[i][3] ? szObjName[i][3] : ' '); PrintSz(sz);
  971.     x = spacex[i]; y = spacey[i]; z = spacez[i];
  972.     sprintf(sz, is.fSeconds ? "[%11.7f] [%11.7f] [%11.7f] [%11.7f] [%11.7f]" :
  973.       "[%7.3f] [%7.3f] [%7.3f] [%7.3f] [%7.3f]",
  974.       planet[i], x, y, z, RSqr(x*x+y*y+z*z)); PrintSz(sz);
  975.     if (!is.fSeconds && i >= uranLo) {
  976.       sprintf(sz, "  Uranian #%d", i-uranLo+1); PrintSz(sz);
  977.     }
  978.     PrintL();
  979.   }
  980.   AnsiColor(kDefault);
  981. }
  982.  
  983.  
  984. /* Print the locations of the astro-graph lines on the Earth as specified */
  985. /* with the -L switch. This includes Midheaven and Nadir lines, zenith    */
  986. /* positions, and locations of Ascendant and Descendant lines.            */
  987.  
  988. void ChartAstroGraph()
  989. {
  990.   CrossInfo FAR *c;
  991.   char sz[cchSzDef];
  992.   real planet1[objMax], planet2[objMax], mc[objMax], ic[objMax],
  993.     as[objMax], ds[objMax], as1[objMax], ds1[objMax],
  994.     lo = Lon, longm, w, x, y, z, ad, oa, am, od, dm;
  995.   int cCross = 0, tot = cObj, i, j, k, l, m, n;
  996.  
  997.   if (us.fLatitudeCross)
  998.     {
  999.     if ((c = (CrossInfo FAR *)
  1000.       PAllocate(sizeof(CrossInfo), fFalse, "crossing table")) == NULL)
  1001.       return;
  1002.     }
  1003.  
  1004. #ifdef MATRIX
  1005.   for (i = 1; i <= cObj; i++) if (!ignore[i]) {
  1006.     planet1[i] = RFromD(Tropical(planet[i]));
  1007.     planet2[i] = RFromD(planetalt[i]);     /* Calculate zenith location on */
  1008.     EclToEqu(&planet1[i], &planet2[i]);    /* Earth of each object.        */
  1009.   }
  1010.  
  1011.   /* Print header. */
  1012.  
  1013.   PrintSz("Object :");
  1014.   for (j = 0, i = 1; i <= cObj; i++)
  1015.     if (!ignore[i] && FThing(i)) {
  1016.       AnsiColor(kObjA[i]);
  1017.       sprintf(sz, " %c%c%c", chObj3(i)); PrintSz(sz);
  1018.       j++;
  1019.     }
  1020.   AnsiColor(kDefault);
  1021.   PrintSz("\n------ :");
  1022.   for (i = 1; i <= tot; i++)
  1023.     if (!ignore[i] && FThing(i))
  1024.       PrintSz(" ###");
  1025.  
  1026.   /* Print the longitude locations of the Midheaven lines. */
  1027.  
  1028.   PrintSz("\nMidheav: ");
  1029.   if (lo < 0.0)
  1030.     lo += rDegMax;
  1031.   for (i = 1; i <= tot; i++)
  1032.     if (!ignore[i] && FThing(i)) {
  1033.     AnsiColor(kObjA[i]);
  1034.     x = RFromD(MC)-planet1[i];
  1035.     if (x < 0.0)
  1036.       x += 2.0*rPi;
  1037.     if (x > rPi)
  1038.       x -= 2.0*rPi;
  1039.     z = lo+DFromR(x);
  1040.     if (z > rDegHalf)
  1041.       z -= rDegMax;
  1042.     mc[i] = z;
  1043.     sprintf(sz, "%3.0f%c", RAbs(z), z < 0.0 ? 'e' : 'w'); PrintSz(sz);
  1044.   }
  1045.   AnsiColor(kDefault);
  1046.  
  1047.   /* The Nadir lines are just always 180 degrees away from the Midheaven. */
  1048.  
  1049.   PrintSz("\nNadir  : ");
  1050.   for (i = 1; i <= tot; i++)
  1051.     if (!ignore[i] && FThing(i)) {
  1052.     AnsiColor(kObjA[i]);
  1053.     z = mc[i] + rDegHalf;
  1054.     if (z > rDegHalf)
  1055.       z -= rDegMax;
  1056.     ic[i] = z;
  1057.     sprintf(sz, "%3.0f%c", RAbs(z), z < 0.0 ? 'e' : 'w'); PrintSz(sz);
  1058.   }
  1059.   AnsiColor(kDefault);
  1060.  
  1061.   /* Print the Zenith latitude locations. */
  1062.  
  1063.   PrintSz("\nZenith : ");
  1064.   for (i = 1; i <= tot; i++)
  1065.     if (!ignore[i] && FThing(i)) {
  1066.       AnsiColor(kObjA[i]);
  1067.       y = DFromR(planet2[i]);
  1068.       sprintf(sz, "%3.0f%c", RAbs(y), y < 0.0 ? 's' : 'n'); PrintSz(sz);
  1069.       as[i] = ds[i] = as1[i] = ds1[i] = rLarge;
  1070.     }
  1071.   PrintL2();
  1072.  
  1073.   /* Now print the locations of Ascendant and Descendant lines. Since these */
  1074.   /* are curvy, we loop through the latitudes, and for each object at each  */
  1075.   /* latitude, print the longitude location of the line in question.        */
  1076.  
  1077.   longm = RFromD(Mod(MC+lo));
  1078.   for (j = 80; j >= -80; j -= us.nAstroGraphStep) {
  1079.     AnsiColor(kDefault);
  1080.     sprintf(sz, "Asc@%2d%c: ", j >= 0 ? j : -j, j < 0 ? 's' : 'n');
  1081.     PrintSz(sz);
  1082.     for (i = 1; i <= tot; i++)
  1083.       if (!ignore[i] && FThing(i)) {
  1084.       AnsiColor(kObjA[i]);
  1085.       ad = RTan(planet2[i])*RTan(RFromD(j));
  1086.       if (ad*ad > 1.0) {
  1087.         PrintSz(" -- ");
  1088.         as1[i] = ds1[i] = cp2.dir[i] = rLarge;
  1089.       } else {
  1090.         ad = RAsin(ad);
  1091.         oa = planet1[i]-ad;
  1092.         if (oa < 0.0)
  1093.           oa += 2.0*rPi;
  1094.         am = oa-rPiHalf;
  1095.         if (am < 0.0)
  1096.           am += 2.0*rPi;
  1097.         z = longm-am;
  1098.         if (z < 0.0)
  1099.           z += 2.0*rPi;
  1100.         if (z > rPi)
  1101.           z -= 2.0*rPi;
  1102.         as1[i] = as[i];
  1103.         as[i] = z = DFromR(z);
  1104.         cp2.dir[i] = ad;
  1105.         sprintf(sz, "%3.0f%c", RAbs(z), z < 0.0 ? 'e' : 'w'); PrintSz(sz);
  1106.       }
  1107.     }
  1108.  
  1109.     /* Again, the Descendant position is related to the Ascendant's,  */
  1110.     /* being a mirror image, so it can be calculated somewhat easier. */
  1111.  
  1112.     AnsiColor(kDefault);
  1113.     sprintf(sz, "\nDsc@%2d%c: ", j >= 0 ? j : -j, j < 0 ? 's' : 'n');
  1114.     PrintSz(sz);
  1115.     for (i = 1; i <= tot; i++)
  1116.       if (!ignore[i] && FThing(i)) {
  1117.       AnsiColor(kObjA[i]);
  1118.       ad = cp2.dir[i];
  1119.       if (ad == rLarge)
  1120.         PrintSz(" -- ");
  1121.       else {
  1122.         od = planet1[i]+ad;
  1123.         dm = od+rPiHalf;
  1124.         z = longm-dm;
  1125.         if (z < 0.0)
  1126.           z += 2.0*rPi;
  1127.         if (z > rPi)
  1128.           z -= 2.0*rPi;
  1129.         ds1[i] = ds[i];
  1130.         ds[i] = z = DFromR(z);
  1131.         sprintf(sz, "%3.0f%c", RAbs(z), z < 0.0 ? 'e' : 'w'); PrintSz(sz);
  1132.       }
  1133.     }
  1134.     PrintL();
  1135. #endif /* MATRIX */
  1136.  
  1137.     /* Now, if the -L0 switch is in effect, then take these line positions, */
  1138.     /* which we saved in an array above as we were printing them, and       */
  1139.     /* calculate and print the latitude crossings.                          */
  1140.  
  1141.     if (us.fLatitudeCross)
  1142.       for (l = 1; l <= cObj; l++) if (!ignore[l] && FThing(l))
  1143.         for (k = 1; k <= cObj; k++) {
  1144.           if (ignore[k] || !FThing(k))
  1145.             continue;
  1146.           for (n = 0; n <= 1; n++) {
  1147.             x = n ? ds1[l] : as1[l];
  1148.             y = n ? ds[l] : as[l];
  1149.             for (m = 0; m <= 1; m++) {
  1150.  
  1151.             /* Check if Ascendant/Descendant cross Midheaven/Nadir. */
  1152.  
  1153.             z = m ? ic[k] : mc[k];
  1154.             if (cCross < MAXCROSS &&
  1155.               RAbs(x-y) < rDegHalf && RSgn(z-x) != RSgn(z-y)) {
  1156.               c->obj1[cCross] = n ? -l : l;
  1157.               c->obj2[cCross] = m ? -k : k;
  1158.               c->lat[cCross] = (real)j+5.0*RAbs(z-y)/RAbs(x-y);
  1159.               c->lon[cCross] = z;
  1160.               cCross++;
  1161.             }
  1162.  
  1163.             /* Check if Ascendant/Descendant cross another Asc/Des. */
  1164.  
  1165.             w = m ? ds1[k] : as1[k];
  1166.             z = m ? ds[k] : as[k];
  1167.             if (cCross < MAXCROSS && k > l &&
  1168.                 RAbs(x-y)+RAbs(w-z) < rDegHalf && RSgn(w-x) != RSgn(z-y)) {
  1169.               c->obj1[cCross] = n ? -l : l;
  1170.               c->obj2[cCross] = 100+(m ? -k : k);
  1171.               c->lat[cCross] = (real)j+5.0*
  1172.                 RAbs(y-z)/(RAbs(x-w)+RAbs(y-z));
  1173.               c->lon[cCross] = Min(x, y)+RAbs(x-y)*
  1174.                 RAbs(y-z)/(RAbs(x-w)+RAbs(y-z));
  1175.               cCross++;
  1176.             }
  1177.           }
  1178.         }
  1179.     }
  1180.   }
  1181.   if (!us.fLatitudeCross)
  1182.     return;
  1183.   PrintL();
  1184.  
  1185.   /* Now, print out all the latitude crossings we found.  */
  1186.   /* First, we sort them in order of decreasing latitude. */
  1187.  
  1188.   for (i = 1; i < cCross; i++) {
  1189.     j = i-1;
  1190.     while (j >= 0 && c->lat[j] < c->lat[j+1]) {
  1191.       SwapN(c->obj1[j], c->obj1[j+1]); SwapN(c->obj2[j], c->obj2[j+1]);
  1192.       SwapR(&c->lat[j], &c->lat[j+1]); SwapR(&c->lon[j], &c->lon[j+1]);
  1193.       j--;
  1194.     }
  1195.   }
  1196.   for (i = 1; i < cCross; i++) {
  1197.     j = abs(c->obj1[i]);
  1198.     AnsiColor(kObjA[j]);
  1199.     sprintf(sz, "%c%c%c ", chObj3(j)); PrintSz(sz);
  1200.     AnsiColor(kElemA[c->obj1[i] > 0 ? eFir : eAir]);
  1201.     PrintSz(c->obj1[i] > 0 ? "Ascendant " : "Descendant");
  1202.     AnsiColor(kWhite);
  1203.     PrintSz(" crosses ");
  1204.     j = abs(c->obj2[i] - (c->obj2[i] < 50 ? 0 : 100));
  1205.     AnsiColor(kObjA[j]);
  1206.     sprintf(sz, "%c%c%c ", chObj3(j)); PrintSz(sz);
  1207.     AnsiColor(kElemA[c->obj2[i] < 50 ?
  1208.       (c->obj2[i] > 0 ? eEar : eWat) : (c->obj2[i] > 100 ? eFir : eAir)]);
  1209.     sprintf(sz, "%s ", c->obj2[i] < 50 ? (c->obj2[i] > 0 ? "Midheaven " :
  1210.       "Nadir     ") : (c->obj2[i] > 100 ? "Ascendant " : "Descendant"));
  1211.     PrintSz(sz);
  1212.     AnsiColor(kDefault);
  1213.     sprintf(sz, "at %s%c,", SzDegree(c->lon[i]),
  1214.       c->lon[i] < 0.0 ? 'E' : 'W'); PrintSz(sz);
  1215.     j = (int)(RFract(RAbs(c->lat[i]))*60.0);
  1216.     sprintf(sz, "%s%c\n", SzDegree(c->lat[i]),
  1217.       c->lat[i] < 0.0 ? 'S' : 'N'); PrintSz(sz);
  1218.   }
  1219.   DeallocateFar(c);
  1220.   if (!cCross) {
  1221.     AnsiColor(kDefault);
  1222.     PrintSz("No latitude crossings.\n");
  1223.   }
  1224. }
  1225.  
  1226.  
  1227. /* Another important procedure: Display any of the types of (text) charts    */
  1228. /* that the user specified they wanted, by calling the appropriate routines. */
  1229.  
  1230. void PrintChart(fProg)
  1231. bool fProg;
  1232. {
  1233.   int fCall = fFalse;
  1234.  
  1235.   if (us.fListing) {
  1236.     if (is.fMult)
  1237.       PrintL2();
  1238.     if (us.nRel < rcDifference)
  1239.       ChartListing();
  1240.     else
  1241.  
  1242.       /* If the -rb or -rd relationship charts are in effect, then instead  */
  1243.       /* of doing the standard -v chart, print either of these chart types. */
  1244.  
  1245.       DisplayRelation();
  1246.     is.fMult = fTrue;
  1247.   }
  1248.   if (us.fWheel) {
  1249.     if (is.fMult)
  1250.       PrintL2();
  1251.     ChartWheel();
  1252.     is.fMult = fTrue;
  1253.   }
  1254.   if (us.fGrid) {
  1255.     if (is.fMult)
  1256.       PrintL2();
  1257.     if (us.nRel > rcDual) {
  1258.       fCall = us.fSmartCusp; us.fSmartCusp = fFalse;
  1259.       if (!FCreateGrid(fFalse))
  1260.         return;
  1261.       us.fSmartCusp = fCall;
  1262.       not(fCall);
  1263.       ChartGrid();
  1264.       if (us.fGridConfig) {    /* If -g0 switch in effect, then  */
  1265.         PrintL();              /* display aspect configurations. */
  1266.         if (!fCall)
  1267.           FCreateGrid(fFalse);
  1268.         DisplayGrands();
  1269.       }
  1270.     } else {
  1271.  
  1272.       /* Do a relationship aspect grid between two charts if -r0 in effect. */
  1273.  
  1274.       fCall = us.fSmartCusp; us.fSmartCusp = fFalse;
  1275.       if (!FCreateGridRelation(us.fGridConfig))
  1276.         return;
  1277.       us.fSmartCusp = fCall;
  1278.       ChartGridRelation();
  1279.     }
  1280.     is.fMult = fTrue;
  1281.   }
  1282.   if (us.fAspList) {
  1283.     if (is.fMult)
  1284.       PrintL2();
  1285.     if (us.nRel > rcDual) {
  1286.       if (!fCall) {
  1287.         fCall = fTrue;
  1288.         if (!FCreateGrid(fFalse))
  1289.           return;
  1290.       }
  1291.       ChartAspect();
  1292.     } else {
  1293.       if (!FCreateGridRelation(fFalse))
  1294.         return;
  1295.       ChartAspectRelation();
  1296.     }
  1297.     is.fMult = fTrue;
  1298.   }
  1299.   if (us.fMidpoint) {
  1300.     if (is.fMult)
  1301.       PrintL2();
  1302.     if (us.nRel > rcDual) {
  1303.       if (!fCall) {
  1304.         if (!FCreateGrid(fFalse))
  1305.           return;
  1306.       }
  1307.       ChartMidpoint();
  1308.     } else {
  1309.       if (!FCreateGridRelation(fTrue))
  1310.         return;
  1311.       ChartMidpointRelation();
  1312.     }
  1313.     is.fMult = fTrue;
  1314.   }
  1315.   if (us.fHorizon) {
  1316.     if (is.fMult)
  1317.       PrintL2();
  1318.     if (us.fHorizonSearch)
  1319.       ChartInDayHorizon();
  1320.     else
  1321.       ChartHorizon();
  1322.     is.fMult = fTrue;
  1323.   }
  1324.   if (us.fOrbit) {
  1325.     if (is.fMult)
  1326.       PrintL2();
  1327.     ChartOrbit();
  1328.     is.fMult = fTrue;
  1329.   }
  1330.   if (us.fInfluence) {
  1331.     if (is.fMult)
  1332.       PrintL2();
  1333.     ChartInfluence();
  1334.     is.fMult = fTrue;
  1335.   }
  1336.   if (us.fAstroGraph) {
  1337.     if (is.fMult)
  1338.       PrintL2();
  1339.     ChartAstroGraph();
  1340.     is.fMult = fTrue;
  1341.   }
  1342.   if (us.fCalendar) {
  1343.     if (is.fMult)
  1344.       PrintL2();
  1345.     if (us.fCalendarYear)
  1346.       ChartCalendarYear();
  1347.     else
  1348.       ChartCalendarMonth();
  1349.     is.fMult = fTrue;
  1350.   }
  1351.   if (us.fInDay) {
  1352.     if (is.fMult)
  1353.       PrintL2();
  1354.     ChartInDaySearch(fProg);
  1355.     is.fMult = fTrue;
  1356.   }
  1357.   if (us.fInDayInf) {
  1358.     if (is.fMult)
  1359.       PrintL2();
  1360.     ChartInDayInfluence();
  1361.     is.fMult = fTrue;
  1362.   }
  1363.   if (us.fEphemeris) {
  1364.     if (is.fMult)
  1365.       PrintL2();
  1366.     ChartEphemeris();
  1367.     is.fMult = fTrue;
  1368.   }
  1369.   if (us.fTransit) {
  1370.     if (is.fMult)
  1371.       PrintL2();
  1372.     ChartTransitSearch(fProg);
  1373.     is.fMult = fTrue;
  1374.   }
  1375.   if (us.fTransitInf) {
  1376.     if (is.fMult)
  1377.       PrintL2();
  1378.     ChartTransitInfluence(fProg);
  1379.     is.fMult = fTrue;
  1380.   }
  1381. #ifdef ARABIC
  1382.   if (us.nArabic) {
  1383.     if (is.fMult)
  1384.       PrintL2();
  1385.     DisplayArabic();
  1386.     is.fMult = fTrue;
  1387.   }
  1388. #endif
  1389.  
  1390.   if (!is.fMult) {          /* Assume the -v chart if user */
  1391.     us.fListing = fTrue;    /* didn't indicate anything.   */
  1392.     PrintChart(fProg);
  1393.     is.fMult = fTrue;
  1394.   }
  1395. }
  1396.  
  1397. /* charts1.c */
  1398.